class_name Stats
extends Node

signal hpChanged
signal expChanged
signal goldChanged
signal levelUp

# 升级点数
var addNum=0
# 等级
@export var level:=0
# 血量
@export var maxHp:=10:
    set(v):
        maxHp=v
        hp=maxHp
@onready var hp:=maxHp:
    set(v):
        v=clampi(v,0,maxHp)
        if hp==v:
            return
        hp=v
        hpChanged.emit()
# 伤害
var damage=0
# 移速
var speed:=600

# 升级所需经验
var levelExp=4
@onready var curExp:=0:
    set(v):
        curExp=v
        if curExp>=levelExp:
            curExp-=levelExp
            levelExp*=3
            level+=1
            addNum+=1
            levelUp.emit()
        expChanged.emit()   
# 金币
@export var gold:=0:
    set(v):
        gold=v
        goldChanged.emit()

# 属性获取倍率
var expRate=1
var goldRate=1
var damageRate=1








